package com.m.utils;

import com.m.job.server.service.MJobRegisterService;
import com.m.job.socket.WebSocketClient;

import lombok.extern.slf4j.Slf4j;

import java.util.HashSet;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;


/**
 * 任务初始化
 * @des
 * @author mengxiangzhong
 * @date 2021年9月1日
 *
 */

@Component
@Slf4j
public class InitializeJobServer implements ApplicationRunner{
	
	@Autowired
	private MJobRegisterService  mJobRegisterService;

	@Override
	public void run(ApplicationArguments args) throws Exception {
		log.info("======《《《任务调度中心启动成功》》》============");
		Thread.sleep(20000L);
		log.info("======准备打印出所有的Socket客户端=============");
		Set<String> serverSet = new HashSet<>();
		serverSet.addAll(WebSocketClient.webSocketMap.keySet());			
		mJobRegisterService.reCleanSocket(serverSet);
		log.info("======结束打印出所有的Socket客户端=============");
	}
	
	

}
